<h2>Matches: [% match.description %]</h2>

<table width="550px">
  <tr>
    <th style="text-align: left;">&nbsp;</th>
    <th style="text-align: right;">Score</th>
  </tr>
  [% FOREACH item IN match.item %]
    [% IF item.id != match.id AND item.description != match.description %]
      <tr>
        <td style="vertical-align: top;padding-right: 10px;">
          <strong>[% IF item.description != "" %][% item.description %][% ELSE %][% item.id %][% END %]</strong><br/>
          [% FOREACH term IN item.term -%]
            [%- IF term != item.term.first -%], [% END %][% term.name -%]
            [%- LAST IF loop.count > 6 -%]
          [%- END %]
        </td>
        <td style="text-align: right; vertical-align: top;">[% FILTER format('%.3lf') %][% item.score %][% END %]</td>
      </tr>
    [% END %]
  [% END %]
</table>

<h3>Profile: [% match.description %]</h3>

<p>
  The following is a list of terms ordered by "tfidf" score. The higher the score, the more discriminating the term is with respect to the other profiles.
  The list shows the term itself (i.e. keyword), the term count (#, i.e. how many times the term occurs within the profiled text), term frequency (tf, i.e. how frequent the term is within this text), inverse document frequency (idf, i.e. how infrequent the term is across all the texts profiled), and "tfidf" (i.e. the product of tf and idf which scores most highly terms which are most discriminating for this text with respect to the other texts). 
</p>

<table width="550px">
  <tr>
    <th style="text-align: left;">Term</th>
    <th style="text-align: right;">#</th>
    <th style="text-align: right;">tf</th>
    <th style="text-align: right;">idf</th>
    <th style="text-align: right;">tf*idf</th>
  </tr>
  [% FOREACH term IN match.term %]
    <tr>
      <td>[% term.name %]</td>
      <td style="text-align: right;">[% term.n %]</td>
      <td style="text-align: right;">[% FILTER format('%.3lf') %][% term.tf %][% END %]</td>
      <td style="text-align: right;">[% FILTER format('%.3lf') %][% term.idf %][% END %]</td>
      <td style="text-align: right;">[% FILTER format('%.3lf') %][% term.tfidf %][% END %]</td>
    </tr>
  [% END %]
</table>

